package com.example.glgk.controller.gather;

import com.example.glgk.dto.DropDownDto;
import com.example.glgk.dto.EscalationDeptData;
import com.example.glgk.dto.QueryEscalation;
import com.example.glgk.dto.UserInfo;
import com.example.glgk.dto.gather.DeptOrderDto;
import com.example.glgk.service.gather.GatherCommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author lxk
 */
@Api(tags = "公共查询接口")
@Slf4j
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/GatherCommonController")
public class GatherCommonController {

    @Autowired
    GatherCommonService gatherCommonService;

    @ApiOperation(value = "查询科室下拉列表")
    @PostMapping("/queryClinicalNames")
    public Map<String,List<String>> queryClinicalNames(){
        return gatherCommonService.queryDeptNames();
    }

    @ApiOperation(value = "指标查询公共科室查询")
    @PostMapping("/queryClinicalData")
    public List<EscalationDeptData> queryClinicalData(@RequestBody QueryEscalation queryEscalation){
        return gatherCommonService.queryDeptData(queryEscalation);
    }

    @ApiOperation(value = "指标查询公共科室查询导出Excel")
    @PostMapping("/export")
    public void export(@RequestBody QueryEscalation queryEscalation, HttpServletResponse response){
        gatherCommonService.export(queryEscalation,response);
    }

    @ApiOperation(value = "查询指标下拉列表")
    @PostMapping("/queryIndicators")
    public  List<DropDownDto> queryIndicators(@RequestBody UserInfo userInfo){
        return gatherCommonService.queryIndicators(userInfo);
    }

    @ApiOperation(value = "查询部门下拉列表")
    @PostMapping("/queryDeptName")
    public Set<String> queryDeptName(){
        return gatherCommonService.queryDeptName();
    }

    @ApiOperation(value = "指标查询公共科室查询导出Excel")
    @PostMapping("/exportGatherClinicalData")
    public void exportGatherClinicalData(@RequestBody QueryEscalation queryEscalation, HttpServletResponse response){
        gatherCommonService.exportGatherClinicalData(queryEscalation,response);
    }

}
